package persistence;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Ivan
 */

public  class DAOQueries   {

    private static  Map<String, String> queries = new HashMap<String, String>();
    
    static{
        
        //GameDAO
        queries.put("GameDAO.getGamesByLeague", "SELECT g FROM Game g,Tournament t WHERE g.tournamentId = t.tournamentId and t.leagueId = :leagueId");
        queries.put("GameDAO.getGamesByTournament", "SELECT g FROM Game g,Tournament t WHERE g.tournamentId = :tournamentId");
        queries.put("GameDAO.getGamesByTeam", "SELECT g FROM Game g , GameContract contract WHERE contract.gameId = g.gameId and contract.teamId = :teamId");
        queries.put("GameDAO.getGamesByOwner", "SELECT g FROM Game g WHERE g.owner = :owner");
        queries.put("GameDAO.getGamesByPlayer", "SELECT g FROM Game g WHERE g.playerId = :playerId");
        queries.put("GameDAO.getWinner", "SELECT t FROM Game g, Team t WHERE t.teamId = q.winnerTeamId  g.gameId = :gameId");
        //-------------------------------------
        
         //LeagueDAO
        queries.put("LeagueDAO.getLeagueByTournament", "SELECT l FROM League l,Tournament t WHERE t.leagueId = l.leagueId and l.tournamentId = :leagueId");
        queries.put("LeagueDAO.getLeagueByGame", "SELECT l FROM League l, Game g,Tournament t WHERE g.tournamentId = t.tournamentId and l.leagueId = t.leagueId and g.gameId = :gameId ");
        queries.put("LeagueDAO.getLeaguesByDiscipline", "SELECT l FROM League l WHERE l.disciplineId = :disciplineId");
        queries.put("LeagueDAO.getLeaguesByOwner", "SELECT l FROM League l WHERE l.owner = :owner");
        queries.put("LeagueDAO.getWinner", "SELECT t FROM League l, Team t WHERE t.teamId = l.winnerTeamId  l.leagueId = :leagueId");
        //-------------------------------------
        
        
         //PlayerDAO
        queries.put("PlayerDAO.getPlayersByTeam", "SELECT l FROM League l,Tournament t WHERE t.leagueId = l.leagueId and l.tournamentId = :leagueId");
        queries.put("PlayerDAO.getPlayersByGame", "SELECT l FROM League l, Game g,Tournament t WHERE g.tournamentId = t.tournamentId and l.leagueId = t.leagueId and g.gameId = :gameId ");
        queries.put("PlayerDAO.getPlayersByOwner", "SELECT l FROM League l WHERE l.disciplineId = :disciplineId");
        queries.put("PlayerDAO.getRatingOfPlayer", "SELECT l FROM League l WHERE l.owner = :owner");
        queries.put("PlayerDAO.changeRating", "SELECT t FROM League l, Team t WHERE t.teamId = l.winnerTeamId  l.leagueId = :leagueId");
        //-------------------------------------
        queries.put("", "");
        queries.put("", "");
        queries.put("", "");
        
    }
    
    public  static String getSQLQuery(String nameQuery) {
       return queries.get(nameQuery);
       
    }
    
    
   
    
}
